package com.project.service.impl;

import com.project.bean.CarBean;
import com.project.mapper.ICarMapper;
import com.project.service.ICarService;
import org.apache.ibatis.session.SqlSession;

public class CarServiceImpl extends BaseService implements ICarService {
    @Override
    public void add(CarBean car, int manId) {
        SqlSession session = this.getSession();
        ICarMapper mapper = session.getMapper(ICarMapper.class);
        mapper.add(car, manId);
        session.commit();
        session.close();
    }

    @Override
    public CarBean findByIdIncludeMan(int id) {
        SqlSession session = this.getSession();
        ICarMapper mapper = session.getMapper(ICarMapper.class);
        CarBean car = mapper.findByIdIncludeMan(id);
        session.close();
        return car;
    }

    public static void main(String[] args) {
        ICarService service = new CarServiceImpl();
//        service.add(new CarBean("bbb", 20000), 1);
        System.out.println(service.findByIdIncludeMan(1));
    }
}
